package com.songcha.library_common.util

import java.lang.reflect.Field

class ResourceUtil {
    companion object{
        //use example:
        //getResId("icon", R.drawable::class.java)
        @JvmStatic
        fun getResId(variableName: String?, c: Class<*>): Int {
            return try {
                val idField: Field = c.getDeclaredField(variableName)
                idField.getInt(idField)
            } catch (e: Exception) {
                e.printStackTrace()
                -1
            }
        }
    }
}